package com.opesoft.calendar.model;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import org.hibernate.annotations.ForeignKey;

@Entity
@Table(name="note")
public class Note implements Serializable
{
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE, generator="NoteIdGenerator")
	@TableGenerator(name="NoteIdGenerator", table="ids", pkColumnName="entity", valueColumnName="maxid", pkColumnValue="Note", allocationSize=1)
	long id;

	@Basic
	@Column(name="ymd", length=8)
	String date; // 发生的日期，因为有些DB中Date可能是关键字，存放的字段名用ymd，格式：YYYYMMDD

	@Basic
	@Column(length=8)
	String startTime; // 开始时间，为空表示是当天的状态。格式：HH:MM 或 HH:MM:SS

	@Basic
	@Column(length=8)
	String endTime; // 结束时间，为空表示是一个时间点

	@Basic
	@Column(length=1024)
	String name; // 事件的标题

	@Basic
	@Column(name="noteType")
	Long noteTypeId; // 类型的ID

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="noteType", insertable=false, updatable=false)
	@ForeignKey(name="fk_note_1")
	NoteType noteType; // 类型的对象

	@Basic
	String ico; // 显示的图标，将来会加入分类，分类中有也有个图标，做为默认

	@Lob
	String remark; // 说明信息

	public long getId()
	{
		return id;
	}

	public void setId(long id)
	{
		this.id=id;
	}

	public String getDate()
	{
		return date;
	}

	public void setDate(String date)
	{
		this.date=date;
	}

	public String getStartTime()
	{
		return startTime;
	}

	public void setStartTime(String startTime)
	{
		this.startTime=startTime;
	}

	public String getEndTime()
	{
		return endTime;
	}

	public void setEndTime(String endTime)
	{
		this.endTime=endTime;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name=name;
	}

	public Long getNoteTypeId()
	{
		return noteTypeId;
	}

	public void setNoteTypeId(Long noteTypeId)
	{
		this.noteTypeId=noteTypeId;
	}

	public NoteType getNoteType()
	{
		return noteType;
	}

	public void setNoteType(NoteType noteType)
	{
		this.noteType=noteType;
	}

	public String getRemark()
	{
		return remark;
	}

	public void setRemark(String remark)
	{
		this.remark=remark;
	}

	public String getIco()
	{
		return ico;
	}

	public void setIco(String ico)
	{
		this.ico=ico;
	}

}
